package com.zzyl.framework.ai;

import com.baidubce.qianfan.Qianfan;
import com.baidubce.qianfan.model.chat.ChatResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class AiInvoker {
    @Value("${qianfan.model}")
    private String model;
    @Value("${qianfan.temperature}")
    private String temperature;

    public String invokeFanChat(String prompt){
        ChatResponse response = new Qianfan().chatCompletion()
                .model(model)
                .addMessage("user",prompt)
                .temperature(Double.valueOf(temperature))
                .responseFormat("json_object")
                .execute();
        return response.getResult();
    }


}
